package com.yuyu.shop.api.convert;

import cn.hutool.core.bean.BeanUtil;
import com.yuyu.shop.api.apimodel.order.dto.OrderSaveOrUpdateDTO;
import com.yuyu.shop.api.apimodel.order.vo.OrderInfoVO;
import com.yuyu.shop.domain.order.DO.OrderCreateDO;
import com.yuyu.shop.domain.order.DO.OrderDO;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author
 * @version 1.0
 * @description: orderConvert
 * @date 2022/8/3 14:59
 */
public class OrderConvert implements Serializable {

    public static OrderDO saveOrUpdateDTO2DO(OrderSaveOrUpdateDTO dto){
        if (Objects.nonNull(dto)){
            OrderDO orderDO = new OrderDO();
            BeanUtil.copyProperties(dto,orderDO);
            return orderDO;
        }
        return null;
    }

    public static OrderInfoVO orderDO2OrderInfoVO(OrderDO orderDO){
        if (Objects.nonNull(orderDO)){
            OrderInfoVO orderInfoVO = new OrderInfoVO();
            BeanUtil.copyProperties(orderDO,orderInfoVO);
            return orderInfoVO;
        }
        return null;
    }

    public static OrderDO saveOrUpdateDTO2DO(OrderCreateDO dto){
        if (Objects.nonNull(dto)){
            OrderDO orderDO = new OrderDO();
            BeanUtil.copyProperties(dto,orderDO);
            orderDO.setReceiveInfo(dto.getReceiveInfoDOS().get(0).toString());
            return orderDO;
        }
        return null;
    }


}
